import { Rectangle } from "../math";
import { Behaviour } from "./Behaviour";
import { Serialized } from "./Serialized";
import { AbstractRenderer } from "./AbstractRenderer";

export class RectangleShapeRenderer extends Behaviour implements AbstractRenderer {

    @Serialized('textInput')
    color = '#000000';
    @Serialized('numberInput')
    width = 100;
    @Serialized('numberInput')
    height = 100;

    bounds = new Rectangle();

    getBounds() {
        this.bounds.width = this.width;
        this.bounds.height = this.height;
        return this.bounds;
    }

    render(context: CanvasRenderingContext2D) {
        context.save();
        context.fillStyle = this.color;
        context.fillRect(0, 0, this.width, this.height);
        context.restore();
    }
}
